/*
 * @Description:
 * @Version:
 * @Autor: tangwc
 * @Date: 2023-05-07 21:43:27
 * @LastEditors: tangwc
 * @LastEditTime: 2023-05-08 21:18:38
 * @FilePath: \stm32_e-paper_demo\User\epa_driver\epaper_driver.h
 *
 *  Copyright (c) 2023 by tangwc, All Rights Reserved.
 */
#ifndef _EPAPER_DRIVER_H_
#define _EPAPER_DRIVER_H_

#include "epa_spi.h"


#define EPA_W   200
#define EPA_H   200

#define EPA_PIN_CTRL    GPIOB
#define EPA_RES_PIN     GPIO_PIN_7
#define EPA_DC_PIN      GPIO_PIN_6
#define EPA_CS_PIN      GPIO_PIN_5
#define EPA_BUSY_PIN    GPIO_PIN_4


#define EPA_RES_CLR HAL_GPIO_WritePin(EPA_PIN_CTRL, EPA_RES_PIN, GPIO_PIN_RESET)
#define EPA_RES_SET HAL_GPIO_WritePin(EPA_PIN_CTRL, EPA_RES_PIN, GPIO_PIN_SET)

#define EPA_DC_CLR HAL_GPIO_WritePin(EPA_PIN_CTRL, EPA_DC_PIN, GPIO_PIN_RESET)
#define EPA_DC_SET HAL_GPIO_WritePin(EPA_PIN_CTRL, EPA_DC_PIN, GPIO_PIN_SET)

#define EPA_CS_CLR HAL_GPIO_WritePin(EPA_PIN_CTRL, EPA_CS_PIN, GPIO_PIN_RESET)
#define EPA_CS_SET HAL_GPIO_WritePin(EPA_PIN_CTRL, EPA_CS_PIN, GPIO_PIN_SET)

#define EPA_BUSY HAL_GPIO_ReadPin(EPA_PIN_CTRL, EPA_BUSY_PIN)


typedef struct {
    uint8_t *Image;
    uint16_t Width;
    uint16_t Height;
    uint16_t WidthMemory;
    uint16_t HeightMemory;
    uint16_t Color;
    uint16_t Rotate;
    uint16_t WidthByte;
    uint16_t HeightByte;
} PAINT;
extern PAINT Paint;


#define ROTATE_0            0   //屏幕正向显示
#define ROTATE_90           90  //屏幕旋转90度显示
#define ROTATE_180          180 //屏幕旋转180度显示
#define ROTATE_270          270 //屏幕旋转270度显示

#define WHITE          0xFF   //显示白色
#define BLACK          0x00   //显示黑色


void EPD_GUIInit(void);
void EPA_Clear(uint16_t Color);
void EPA_Display(unsigned char *Image);
void Paint_NewImage(uint8_t *image, uint16_t Width, uint16_t Height, uint16_t Rotate, uint16_t Color);
void EPA_DrawPoint(uint16_t Xpoint, uint16_t Ypoint, uint16_t Color);
void EPA_ShowPicture(uint16_t x, uint16_t y, uint16_t sizex, uint16_t sizey, const uint8_t BMP[], uint16_t Color);

#endif